Conventionally, a stroke amount detecting device, which includes a magnet as a magnetic field generating means and a magnetism detecting element that is displaced relative to the magnet in accordance with a linear movement of a detection object to detect a change of a magnetic field, and which detects a stroke amount of the detection object based on an output signal of the magnetism detecting element, is known. For example, as illustrated in FIG. 6, in a device 60 described in JP-A-2008-45919, four magnets 62a, 62b, 63a, 63b are arranged on one side and the other side within a stroke range to be opposed to each other. Polarities of the opposed magnets are in the same direction, and polarities of adjacent magnets on one side and the other side of the stroke range are in the opposite direction. For this reason, a direction of magnetic flux (arrows in FIG. 6) is reversed on one side and the other side in the stroke range. In addition, a magnetism detecting element 61x is disposed between the opposed magnets.
If a magnetic foreign substance such as iron powder enters into the device in JP-A-2008-45919, it is assumed that the iron powder Fe attaches between the opposed magnets, as illustrated in FIG. 6. In a process of the attachment of the iron powder Fe, first, the iron powder Fe deposits gradually on surfaces of the opposed magnets. At the time of this deposition, a gap between the magnets becomes narrow due to the iron powder Fe, so that the magnetic flux can become strong. The iron powder Fe deposits further, and if the gap between the opposed magnets is bridged as indicated by a broken line in FIG. 6, the magnetic flux disappears. In this manner, due to the attachment of the magnetic foreign substance such as iron powder, characteristics of the device in JP-A-2008-45919 may change, and detection accuracy of the device may be reduced.